package com.lib.common.helper.api

import com.google.gson.annotations.SerializedName

/**
 * Copyright (C), 2020-2020, 享物说
 * FileName: ApiResponse
 * Author: keanbin
 * Date: 2020-02-06 16:45
 * Description: api 返回结果
 * History:
 * <author> <time> <version> <desc>
 * 作者姓名 修改时间 版本号 描述
 */
data class ApiResponse<T>(
    val success: Boolean = true,
    val data: T? = null,
    @SerializedName("err")
    var error: ResponseError? = null
) {

    /**
     * 获取错误提示
     */
    fun getErrorText(): String? {
        return error?.message
    }
}

data class ResponseError(
    @SerializedName(value = "code", alternate = ["ec"])
    val code: String = "0",

    @SerializedName(value = "message", alternate = ["em"])
    val message: String? = null
)